package training.sample.app.repository.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import training.sample.app.domain.Country;
import training.sample.app.repository.CountryDao;
import training.sample.app.repository.base.AbstractHibernateDao;

@Repository
public class CountryRepository extends AbstractHibernateDao<Country, Long> implements CountryDao {
	
	@Override
	public Country findById(Long countryId) {
		Criteria cr = getSession()
				.createCriteria(Country.class, "country")
				.add(Restrictions.eq("id", countryId));
		return (Country) cr.uniqueResult();
	}
	
}